import React, { FC } from 'react';
import ReactEcharts from 'echarts-for-react';

const PieChart:FC<{data:{value:number,name:string}[]}> = ({data}) => {
  const getOption = () => {
    return {
      title: {
        text: '角色数量分析',
        textStyle: {
          fontWeight: 'normal',
          fontSize: 16,
        },
        left: 'center',
        top: 20,
      },
      tooltip: {
        trigger: 'item',
      },
      legend: {
        orient: 'vertical',
        left: 'left'
      },
      series: [
        {
          name: '访问来源',
          type: 'pie',
          radius: ['40%', '60%'],
          avoidLabelOverlap: false,
          label: {
            show: false,
            position: 'center',
          },
          emphasis: {
            label: {
              show: true,
              fontSize: '30',
              fontWeight: 'bold',
            },
          },
          labelLine: {
            show: false,
          },
          data: data,
        },
      ],
    };
  };

  return <ReactEcharts option={getOption()} />;
};

export default PieChart;